package edu.jd.movieplatform.user.long_comment;

import edu.jd.movieplatform.common.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user/long_comment")
public class LongCommentAPI{
    @Resource
    private LongCommentService Service;

    /**
     * 用户添加长评
     * 需要参数：
     *     private String cust_username;
     *     private Integer mov_id;
     *     private String com_text;
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody LongCommentDto dto){
        boolean ok = Service.CreateLongComment(dto);
        if(ok){return Result.success();}
        return Result.fail(Result.ERR_CODE_BUSINESS,"影评出错！");
    }

    /**
     * 获取长评
     *  需要参数：
     *  private Integer mov_id;
     */
    @PostMapping("/getComment")
    public Result getComment(@RequestBody LongCommentDto dto){
        Integer mov_id=dto.getMov_id();
        List<LongComment> list = Service.GetLongCommentList(mov_id);
        return Result.success(list);
    }
}
